﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace blackhouse.BlackApart.Business.PushMails {
    public class QuickContactPushMail {

        #region Fields

        private IPushMail pushMail;
        
        #endregion

        #region Properties

        public string PhoneNumber { get; set; }

        #endregion

        #region Constructors

        public QuickContactPushMail(string phoneNumber) {
            this.pushMail = Factory.Instance().MakePushMail();
            this.PhoneNumber = phoneNumber;
        }

        #endregion

        #region Methods

        public void PushMail() {
            string mails = ConfigurationManager.AppSettings["QuickContactReceivers"];
            string[] ms;
            if (string.IsNullOrEmpty(mails) || ( ms = mails.Split(';') ).Length == 0)
                throw new ArgumentNullException("Brak AppSetting o kluczu QuickContactReceivers. NIe wiadomo gdzie wysłać maila");
            this.PushMail(ms);
        }

        public void PushMail(params string[] mails) {
            this.pushMail.Content = @"Nasz klient poprosił o szybki kontakt.\r\nJego numer telefonu to: " + this.PhoneNumber;
            this.pushMail.IsHtml = false;
            this.pushMail.Title = "Prośba o szybki kontakt";
            this.pushMail.To = mails;
            this.pushMail.Save();
        }

        #endregion

    }
}
